	import {
		pathToBase64,
		base64ToPath
	} from '@/utils/image-tool.js'
	export default {
		data() {

			return {
				homelist: {},
				type: 1,
				index: 0,

				buttonClick: 0,
				buttonDay: 0,
				isActive: 0,
				inday: 0,

				ruleForm: {
					renType: null,
				},
				housingFlag: false,
				hourseList: null,
				hourseStr: null,
				hourseNum: 0, //选择第几个房间,
				projectList: [],
				modalShow: false,
				pageIndex: 1,
				project_id: null,
				renovate_state: 7,
				tableData: [], //获取装修记录
				applyForm: {
					code: null,
					user_id: null,
					project_id: null, //项目id
					renovate_district: null, //装修区号
					renovate_floor: null, //装修楼号
					renovate_unit: null, //装修单元
					renovate_house_number: null, //装修门牌号
					renovate_type: 1, //装修类型: 1.装修公司装修  2.自己装修
					renovate_deposit: null, //装修押金
					renovate_begin_time: null, //装修开始时间
					renovate_last_time: '', //装修结束时间
					renovate_outsource_org_name: null, //外包公司单位名称
					renovate_outsource_org_tel: null, //外包单位电话
					renovate_address: null, //详细地址
					renovate_owner_name: null, //装修负责人名称
					renovate_owner_tel: null, //装修负责人电话
					renovate_contract_image: null, //装修合同图
					renovate_licence_image: null, //营业执照图
					renovate_construct_image: null, //装修施工图
					renovate_result_image: null, //装修效果图
					worker_data: [{
						worker_name: null,
						worker_card: null,
						worker_tel: null,
						worker_image: null,
						renovation: false,
						state1: false,
						state3: false,
						state4: false,
					}], //装修工人信息

					renovate_payee: null, //收款人
					renovate_collect_way: null, //收款方式
					renovate_personal_pay_proof: null, //凭证
					phone: uni.getStorageSync('projectItem').ownerTel,
					room_id: uni.getStorageSync('projectItem').roomId,
					money: null,
					application: 2,
				},
				MoneyData: {},
				daterange: [],
				paymentMode: null, //1、微信支付    2、支付宝支付
				chargeList: {},
				loading: false,
				// type: 1,
				nextPage: false,
				listData: [],
				radio: false,
				show: false,

				renovaStat: true,

				//微信
				weChat: true,
				//支付宝
				alipay: false,
				// 
				renovation: false,
				passThrough: false,
				 // 上传接口参数
					option: {
							// 上传服务器地址，需要替换为你的接口地址
							url:'http://192.168.101.162:8900/rest/v1/venusSysModelServiceImpl/uploadFile',
							//url:'https://admin.515f.com/api/ue/uploadFile',
							//url: 'http://hl.j56.com/dropbox/document/upload', // 该地址非真实路径，需替换为你项目自己的接口地址
							// 上传附件的key
							name: 'file',
							// 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
							header: {
									// // 示例参数可删除
									// 'Authorization': 'bearer eyJhbGciOiJSUzI1NiIsI',
									// 'uid': '99',
									// 'client': 'app',
									// 'accountid': 'DP',
							},
							// 根据你接口需求自定义body参数
							formData: {
								file:'123456',
								oldFile:'',
								//'orderId': 1000
							}
						},
						// 选择文件后是否立即自动上传，true=选择后立即上传
						instantly: true,
						// 必传宽高且宽高应与slot宽高保持一致
						width: '180rpx',
						height: '180rpx',
						// 限制允许上传的格式，空串=不限制，默认为空
						formats: '',
						// 文件上传大小限制
						size: 30,
						// 文件数量限制
						count: 2,
						// 文件回显列表
						files: new Map(),
						// 微信小程序Map对象for循环不显示，所以转成普通数组，不要问为什么，我也不知道
						wxFiles: [],
						// 是否打印日志
						debug: true,
						// 演示用
						tabIndex: 0,
						list:[],
						pdfUrl:'',
						pdfName:'',//name
			}
		},
		async onShow() {
			this.checkLogin();
		//	// #ifdef APP-PLUS
			let appOpenParam = plus.runtime.arguments || 0
			try{
					let objParam = JSON.parse(appOpenParam)
			}catch(e){
				//TODO handle the exception
				if (appOpenParam) {
					let params = JSON.stringify(appOpenParam);
					let parSix = params.substring(params.indexOf('zhuye-') + 20, params.lastIndexOf('//')); //params.length-1
					this.pdfName =  decodeURI(params.substring(params.lastIndexOf('//')+2,params.length-1));
					this.pdfUrl = parSix;
					//console.log(this.pdfName,this.pdfUrl,'--pdf成功-----')
				}
			}			
		//	//#endif
			
			setTimeout(()=>{
					console.log('----演示动态更新参数-----');
					this.$refs['lsjUpload'+this.tabIndex].setData('formData.orderId','动态设置的参数'); 
					// 初始化tab
					this.onTab(0);
			},2000)
		},
		onPullDownRefresh() {
			// let res = await this.$request.api.address({})
			this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
			console.log(this.homelist)
			this.housingFlag = false
			// this.renovation()
			this.getwhetherList()
			this.getrenovation()
		},
		methods: {
			chooseFile(){
				console.log('-----上传')
					let images = [];
				uni.chooseFile({
				  count: 6, //默认100
				  extension:['.pdf','.doc'],
					success: function (res) {
						console.log(res,'-----------------------')
						console.log(JSON.stringify(res.tempFilePaths),res.tempFilePaths[0]);
					 images = res.tempFilePaths || []
						for(let i=0;i<images.length;i++){
							pathToBase64(res.tempFilePaths[0]).then(res => {
								uni.request({
										url:'https://admin.515f.com/api/weixin/applet/base64_to_image_url',
										//url: 'http://192.168.101.162:8900/rest/v1/venusSysModelServiceImpl/uploadFile', 
										method: 'POST',
										data: {
											imageBase64:  res
										},
										success: res2 => {
											console.log(res2.data.data,'-----------上传成功');
										}
									})
							})
						}
					}
				});
			},
			
				/**
				 * 某文件上传结束回调(成功失败都回调)
				 * @param {Object} item 当前上传完成的文件
				*/
				onuploadEnd(item) {
					//console.log(this.option.formData.file,'---fileName-0001-')
					//console.log(`${item.name}已上传结束，上传状态=${item.type}`);
					// 更新当前窗口状态变化的文件
					this.files.set(item.name,item);
					// ---可删除--演示上传完成后取服务端数据
					if (item['responseText']) {
							console.log('演示服务器返回的字符串JSON转Object对象');
							this.files.get(item.name).responseText = JSON.parse(item.responseText);
					}
					// 微信小程序Map对象for循环不显示，所以转成普通数组，
					// 如果你用不惯Map对象，也可以像这样转普通数组，组件使用Map主要是避免反复文件去重操作
					// #ifdef MP-WEIXIN
					this.wxFiles = [...this.files.values()];
					// #endif
					// 强制更新视图
					this.$forceUpdate();
					// ---可删除--演示判断是否所有文件均已上传成功
					let isAll = [...this.files.values()].find(item=>item.type!=='success');
					if (!isAll) {
						//	console.log('已全部上传完毕');
					}else {
					//	console.log(isAll.name+'待上传');
					}
				},
				/**
				 * 上传进度回调
				 * 如果网页上md文档没有渲染出事件名称onprogre，请复制代码的小伙伴自行添加上哈，没有哪个事件是只(item)的
				 * @param {Object} item 当前正在上传的文件
				 */
				onprogre(item) {
						//console.log(this.option.formData.file,'---fileName-0002-')
						// 更新当前状态变化的文件
						this.files.set(item.name,item);
						let path = this.files.get(item.name).path;
						this.base64Fun(path)
						console.log('打印对象------------',this.files.get(item.name).path);
						
						
						// 微信小程序Map对象for循环不显示，所以转成普通数组，不要问为什么，我也不知道
						// #ifdef MP-WEIXIN
						this.wxFiles = [...this.files.values()];
						// #endif
						// 强制更新视图
						this.$forceUpdate();
				},
				base64Fun(path){
					console.log(path,'-------ptasdfjsdlkfjsdf------')
					//pathToBase64(res.tempFilePaths[0]).then(res => {
					base64ToPath(path).then(res => {
						console.log(res,'================res---')
						uni.request({
							 //url:'http://192.168.101.162:8900/api/weixin/applet/base64_to_image_url',
								 url:'https://admin.515f.com/api/weixin/applet/base64_to_image_url',
								//url: 'http://192.168.101.162:8900/rest/v1/venusSysModelServiceImpl/uploadFile', 
								method: 'POST',
								data: {
									imageBase64:  res
								},
								success: res2 => {
									console.log(res2.data.data,'==========上传成功');
								}
							})
					}).catch(e=>{
						console.log(e,'-------------------------111111111111111-----')
					})
				},
			/**
			 * 文件选择回调
			 * @param {Object} files 已选择的所有文件Map集合
			 */
			change(files) {
			//	console.log(JSON.stringify(files),'-------------000003333')
			//	console.log('当前选择的文件列表：55--',JSON.stringify([...files.values()]));
				// 更新选择的文件 
				this.files = files;
				// 强制更新视图
				this.$forceUpdate();
				// 微信小程序Map对象for循环不显示，所以转成普通数组，不要问为什么，我也不知道
				// #ifdef MP-WEIXIN
				this.wxFiles = [...this.files.values()];
				// #endif
				// ---可删除--演示重新定位覆盖层控件
				this.$nextTick(()=>{
						console.log('演示重新定位');
						this.$refs.lsjUpload0.show();
						this.$refs.lsjUpload1.show();
						this.$refs.lsjUpload2.show();
				});
			},			

			proof1(index, val) {
				console.log('校验手机号')
				const phoneValid = this.checkPhoneNumber(val);
				console.log(phoneValid, '校验结果')
				if (phoneValid) {
					this.applyForm.worker_data[index].state3 = true
				} else {
					this.applyForm.worker_data[index].state3 = false
				}
			},
			proof2(index, val) {
				console.log('校验身份证号')
				const idCardValid = this.validateIDCard2(val);
				console.log(idCardValid, '校验结果')
				if (idCardValid) {
					this.applyForm.worker_data[index].state4 = true
				} else {
					this.applyForm.worker_data[index].state4 = false
				}
			},

			handleWechat(num) {
				if (num == 1) {
					this.weChat = true
					this.alipay = false
				} else {
					this.alipay = true
					this.weChat = false
				}
			},

			// 示例用法

			// 验证是否登录或实名认证
			checkLogin() {
				let _this = this
				if (uni.getStorageSync('phone')) {
					if (uni.getStorageSync('loginFlag')) {
						if (!uni.getStorageSync('hourseList')) {
							uni.showModal({
								title: '请先进行业主认证',
								showCancel: false,
								confirmText: '确认',
								confirmColor: '#F9A832',
								success: function(res) {
									if (res.confirm) {
										_this.$Router.push({
											path: '/pages/address/address'
										})
									}
								}
							});
							this.$openInvite()
						} else {
							_this.showFlag = true
							_this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
							_this.name = _this.homelist.proName;
							_this.address = _this.homelist.buildDistrictCode + '-' + _this.homelist.buildTowerCode + '-' +
								_this.homelist.roomUnitNumber + '-' + _this.homelist.roomCode
							let res = this.$request.api.address({})
							this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
							console.log(this.homelist)
							this.housingFlag = false
							// this.renovation()
							this.getwhetherList()
							this.getrenovation()
							// this.getdepositList()
						}
					} else {
						uni.showModal({
							title: '请先实名认证',
							showCancel: false,
							confirmText: '确认',
							confirmColor: '#F9A832',
							success: function(res) {
								if (res.confirm) {
									_this.$Router.push({
										path: '/pages/realName/realName'
									})
								}
							}
						});
					}
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
						confirmText: '确认',
						confirmColor: '#F9A832',
						success: function(res) {
							if (res.confirm) {
								console.log('a')
								_this.$Router.pushTab({
									path: '/pages/user/user'
								})
							}
						}
					});
				}
				uni.stopPullDownRefresh();

			},
			code1() {
				this.paymentMode = 2
				console.log(this.paymentMode)
			},
			chargeBtn() {
				// 打开支付宝里面的搜索：  alipayqr://platformapi/startapp?saId=20001003
				// 支付宝收款码:   alipayqr://platformapi/startapp?saId=20000123
				// 支付宝扫一扫：alipayqr://platformapi/startapp?saId=10000007
				// 支付宝付款：alipay://platformapi/startapp?appId=20000056
				//let authUrl = `alipays://platformapi/startapp?appId=20000067&url=HTTPS%3a%2f%2fQR.ALIPAY.COM%2fFKX09099VQZDCJ1QFGXA9F`;
				//let authUrl = `alipays://platformapi/startapp?appId=2021002127637334&url=${encodeURIComponent('345%^4567657path:009')}`;
				//const query = encodeURIComponent('要带的参数')
				//plus.runtime.openURL("alipays://platformapi/startapp?appId=要跳转的支付宝小程序appid&要跳转的页面" + 要带的参数);
				//const URL = encodeURIComponent('https://www.515f.com/adapay?key=WY2022031919171531&money=0.30&proId=54')
				console.log(this.chargeList.data.money, "==================dad1")
				const order = this.chargeList.data.code; //订单编号
				const money = Number(this.chargeList.data.money).toFixed(2); //金额
				const proId = this.chargeList.data.pro_id;
				const URL = encodeURIComponent(`https://www.515f.com/adapay?key=${order}&money=${money}&proId=${proId}`);
				let authUrl = `alipays://platformapi/startapp?saId=10000007&qrcode=` + URL;
				//console.log(authUrl);
				plus.runtime.openURL(authUrl, function(res) {
					uni.showToast({
						icon: "none",
						title: "请安装支付宝之后再进行支付！",
					});
				});
			},
			bindDateChange: function(e) {
				this.applyForm.renovate_begin_time = e.f3;
				this.applyForm.renovate_last_time = e.f3;
				this.daterange = e
				console.log(this.applyForm.renovate_begin_time)
				console.log(this.applyForm.renovate_last_time)
				console.log(this.daterange)
				// this.date = e.detail.value
			},
			//whetherList是否可以缴费
			async getwhetherList() {
				uni.showLoading({
					title: "加载中"
				})
				let res = this.$request.api.whetherList({
					project_id: this.homelist.proId,
					room_id: this.homelist.roomId,
					// room_id:uni.getStorageSync('projectItem').roomId
				}).then(res => {
					if (res.data.code == 0) {
						this.applyForm.money = res.data.data.deposit;

					} else {
						uni.showModal({
							title: '提示',
							content: '请先进行装修设置操作！',
							showCancel: false,
							success: function(res) {
								uni.reLaunch({ //跳转页面
									url: "/pages/index/index"
								})
							}
						});
					}
					uni.hideLoading()
					uni.stopPullDownRefresh()
				})
			},
			//renovation是否正在装修中
			async getrenovation() {
				let count = 0;
				let res = this.$request.api.renovation({
					room_id: this.homelist.roomId,
				}).then(res => {
					console.log(res)
					if (res.data.code == -1) {
						this.isActive = 1
						this.renovaStat = false;



					}
				})
			},

			//收取押金
			getdepositList() {

				// var beginTime = this.applyForm.renovate_begin_time[0]
				// var endTime = this.applyForm.renovate_begin_time[1]
				// this.applyForm.renovate_begin_time = beginTime;
				// this.applyForm.renovate_last_time = beginTime
				let res = this.$request.api.depositList(this.applyForm, {

				}).then(res => {
					this.chargeList = res.data
					console.log(this.chargeList, "---------------------------dad1")
					// console.log(res)
				})
			},
			//跳转支付宝收费
			//下拉刷新
			// onRefresh() {
			// 	if (!this.nextPage) {
			// 		this.pageIndex = this.pageIndex + 1;
			// 		this.renovation();
			// 	}
			// },
			//获取装修记录
			async renovation() {
				if (this.pageIndex < 2) {
					uni.showLoading({
						title: '加载中'
					});
				}
				this.loading = false;
				let res = await this.$request.api.renovationList({
					pageIndex: this.pageIndex,
					// renovate_state:3,
					room_id: this.homelist.roomId,
					ownerApp: 1,
					// room_id: 49425,

				}).then(res => {
					console.log(res)
					if (this.pageIndex == 1) {
						this.tableData = res.data.data.datalist || [];
					} else {
						this.tableData = [...this.tableData, ...res.data.data.datalist];
					}
					console.log(this.tableData)
					this.nextPage = res.data.data.isEndPage
					this.loading = true;
					uni.hideLoading();
					// this.tableData = res.data.data.datalist
					// console.log(res)
				})
			},
			checked(index) {


				if (this.renovaStat) {
					this.isActive = index;
				} else {
					this.isActive = 1;
				}

				if (this.isActive === 1) {
					this.renovation();
				}
			},
			//页面跳转
			navTo(url, item) {
				let items = encodeURIComponent(JSON.stringify(item))
				uni.navigateTo({
					url: url + '?item=' + items
				});

			},
			nuxt: function(index) {
				if (index == 1) {
					if (this.applyForm.renovate_type == null) {
						uni.showModal({
							title: '提示',
							content: '请选择装修类型！',
							showCancel: false,
							success: function(res) {

							}
						});
						return;
					}

					if (this.daterange.length == 0) {
						uni.showModal({
							title: '提示',
							content: '选择装修周期！',
							showCancel: false,
							success: function(res) {

							}
						});
						return;
					}

					if (!this.radio == 1) {
						uni.showModal({
							title: '提示',
							content: '请同意协议！',
							showCancel: false,
							success: function(res) {

							}
						});
						return;
					}
					if (this.applyForm.renovate_type == 1) {
						this.buttonClick = 1
					} else {
						this.buttonClick = 2;
					}
				} else if (index == 2) {
					if (this.buttonClick == 1) {
						if (!this.applyForm.renovate_outsource_org_name) {
							uni.showModal({
								title: '提示',
								content: '公司装修请填写公司名称！',
								showCancel: false,
								success: function(res) {},
							});
							return;
						}
						if (!this.applyForm.renovate_address) {
							uni.showModal({
								title: '提示',
								content: '公司装修请填写公司地址！',
								showCancel: false,
								success: function(res) {},
							});
							return;
						}
						if (!this.applyForm.renovate_outsource_org_tel) {
							uni.showModal({
								title: '提示',
								content: '公司装修请填写公司电话！',
								showCancel: false,
								success: function(res) {},
							});
							return;
						}
						if (!this.applyForm.renovate_outsource_org_name) {
							uni.showModal({
								title: '提示',
								content: '公司装修请填写负责人姓名！',
								showCancel: false,
								success: function(res) {},
							});
							return;
						}
						if (!this.applyForm.renovate_owner_tel) {
							uni.showModal({
								title: '提示',
								content: '公司装修请填写负责人电话！',
								showCancel: false,
								success: function(res) {},
							});
							return;
						}


						if (!this.applyForm.renovate_contract_image) {
							uni.showModal({
								title: '提示',
								content: '请上传装修合同！',
								showCancel: false,
								success: function(res) {

								},
							});
							return;
						}

						if (!this.applyForm.renovate_licence_image) {
							uni.showModal({
								title: '提示',
								content: '请上传营业执照！',
								showCancel: false,
								success: function(res) {

								},
							});
							return;
						}

					}

					this.buttonClick = 3


				} else if (index == 3) {
					console.log(this.applyForm.worker_data, "-------------装修工人信息")

					for (let i = 0; i < this.applyForm.worker_data.length; i++) {
						if (i == 1) {
							let selindex = this.applyForm.worker_data[i];
							const idCardValid = this.validateIDCard2(selindex.worker_card);
							if (idCardValid == false) {
								uni.showModal({
									title: '提示',
									content: '请检查身份证号!!!',
									showCancel: false,
									success: function(res) {

									},
								});
								return;
							}
							const phoneValid = this.checkPhoneNumber(selindex.worker_tel);
							if (phoneValid == false) {
								uni.showModal({
									title: '提示',
									content: '请检查手机号!!!',
									showCancel: false,
									success: function(res) {

									},
								});
								return;
							}
						}

					}
					this.buttonClick = 4;
					this.getdepositList()
				}
			},



			validateIDCard2(idCard) {
				console.log(idCard)
				// 身份证正则表达式
				const idCardRegex = /^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/;
				return idCardRegex.test(idCard);
			},
			checkPhoneNumber: function(phoneNumber) {
				var reg = /^1[3456789]\d{9}$/;
				return reg.test(phoneNumber)
			},



			nuxtS(index) {
				if (index == 1) {
					this.buttonClick = 0;
				} else if (index == 2) {
					if (this.applyForm.renovate_type == 1) {
						this.buttonClick = 1;
					} else {
						this.buttonClick = 2;
					}
				}
			},
			//装修合同
			colseImg1(val) {
				this.applyForm.renovate_contract_image = null;
				if (!this.applyForm.renovate_contract_image) {
					this.imgFlag = true
				}
			},
			//打开pdf
			openPdf(url){
				plus.runtime.openURL(url)
			},
			closePdf(){
				this.pdfUrl = '';
			},
			// 选择图片
			uoloadHouse1() {
				//浏览器打开上传pdf 
				// plus.runtime.openURL('https://s.515f.com/#/pages/uploadPhone/uploadFile')
				// return;
				let _this = this;
				uni.showActionSheet({
					itemList: ['手机拍照', '本地图片上传'],
					success: function(res) {
						uni.showLoading({title: '上传中'});
						if (res.tapIndex == 0) {
							uni.chooseImage({
								count: 1, //默认9
								sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
								sourceType: ['camera '],
								success: function(res) {
									pathToBase64(res.tempFilePaths[0]).then(res => {
										_this.$request.api.image({
											imageBase64: res
										}).then(res => {
											_this.applyForm.renovate_contract_image = res.data.data
											_this.imgFlag = false;
											uni.hideLoading();
										})
									})
								}
							})
						} else {
							uni.chooseImage({
								count: 1, //默认9
								sizeType: ['original', 'compressed'],
								sourceType: ['album  '],
								success: function(res) {
									pathToBase64(res.tempFilePaths[0]).then(res => {
										_this.$request.api.image({
											imageBase64: res
										}).then(res => {
											_this.applyForm
												.renovate_contract_image = res.data
												.data
											_this.imgFlag = false;
											uni.hideLoading();
										})
									})
								}
							});
						}
					},
					fail: function(res) {}
				});
			},
			//营业执照
			colseImg(val) {
				this.applyForm.renovate_licence_image = null;
				if (!this.applyForm.renovate_licence_image) {
					this.imgFlag = true
				}
			},
			// 选择图片
			uoloadHouse() {
				let _this = this;
				uni.showActionSheet({
					itemList: ['手机拍照', '本地图片上传'],
					success: function(res) {
						uni.showLoading({
							title: '上传中'
						});
						if (res.tapIndex == 0) {
							uni.chooseImage({
								count: 1, //默认9
								sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
								sourceType: ['camera '],
								success: function(res) {
									pathToBase64(res.tempFilePaths[0]).then(res => {
										_this.$request.api.image({
											imageBase64: res
										}).then(res => {
											_this.applyForm
												.renovate_licence_image = res.data
												.data
											_this.imgFlag = false;
											uni.hideLoading();
										})
									})
								}

							})
						} else {
							uni.chooseImage({
								count: 1, //默认9
								sizeType: ['original', 'compressed'],
								sourceType: ['album  '],
								success: function(res) {
									pathToBase64(res.tempFilePaths[0]).then(res => {
										_this.$request.api.image({
											imageBase64: res
										}).then(res => {
											_this.applyForm
												.renovate_licence_image = res.data
												.data
											_this.imgFlag = false;
											uni.hideLoading();
										})
									})
								}

							});
						}
					},
					fail: function(res) {}
				});
			},
			//装修施工图
			colseImg2(val) {
				this.applyForm.renovate_construct_image = null;
				if (!this.applyForm.renovate_construct_image) {
					this.imgFlag = true
				}
			},
			// 选择图片
			uoloadHouse2() {
				let _this = this;
				uni.showActionSheet({
					itemList: ['手机拍照', '本地图片上传'],
					success: function(res) {
						uni.showLoading({
							title: '上传中'
						});
						if (res.tapIndex == 0) {
							uni.chooseImage({
								count: 1, //默认9
								sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
								sourceType: ['camera '],
								success: function(res) {
									pathToBase64(res.tempFilePaths[0]).then(res => {
										_this.$request.api.image({
											imageBase64: res
										}).then(res => {
											_this.applyForm
												.renovate_construct_image = res
												.data.data
											_this.imgFlag = false;
											uni.hideLoading();
										})
									})
								}

							})
						} else {
							uni.chooseImage({
								count: 1, //默认9
								sizeType: ['original', 'compressed'],
								sourceType: ['album  '],
								success: function(res) {
									pathToBase64(res.tempFilePaths[0]).then(res => {
										_this.$request.api.image({
											imageBase64: res
										}).then(res => {
											_this.applyForm
												.renovate_construct_image = res
												.data.data
											_this.imgFlag = false;
											uni.hideLoading();
										})
									})
								}

							});
						}
					},
					fail: function(res) {}
				});
			},
			//装修效果图
			colseImg3(val) {
				this.applyForm.renovate_result_imagee = null;
				if (!this.applyForm.renovate_result_image) {
					this.imgFlag = true
				}
			},
			// 选择图片
			uoloadHouse3() {
				let _this = this;
				uni.showActionSheet({
					itemList: ['手机拍照', '本地图片上传'],
					success: function(res) {
						uni.showLoading({
							title: '上传中'
						});
						if (res.tapIndex == 0) {
							uni.chooseImage({
								count: 1, //默认9
								sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
								sourceType: ['camera '],
								success: function(res) {
									pathToBase64(res.tempFilePaths[0]).then(res => {
										_this.$request.api.image({
											imageBase64: res
										}).then(res => {
											_this.applyForm.renovate_result_image =
												res.data.data
											_this.imgFlag = false;
											uni.hideLoading();
										})
									})
								}

							})
						} else {
							uni.chooseImage({
								count: 1, //默认9
								sizeType: ['original', 'compressed'],
								sourceType: ['album  '],
								success: function(res) {
									pathToBase64(res.tempFilePaths[0]).then(res => {
										_this.$request.api.image({
											imageBase64: res
										}).then(res => {
											_this.applyForm.renovate_result_image =
												res.data.data
											_this.imgFlag = false;
											uni.hideLoading();
										})
									})
								}

							});
						}
					},
					fail: function(res) {}
				});
			},



			//新增工人信息
			addPeoperBtn() {
				this.applyForm.worker_data.push({
					worker_name: null,
					worker_card: null,
					worker_image: null,
					renovation: false,
					state1: false,
					state3: false,
					state4: false,
				});
			},

			jianche(item) {
				console.log(item)

				const idCardValid = this.validateIDCard2(item.worker_card);
				console.log(idCardValid)
				if (idCardValid == false) {
					uni.showModal({
						title: '提示',
						content: '请检查身份证号!!!',
						showCancel: false,
						success: function(res) {

						},
					});
					return;
				}
				const phoneValid = this.checkPhoneNumber(item.worker_tel);
				if (phoneValid == false) {
					uni.showModal({
						title: '提示',
						content: '请检查手机号!!!',
						showCancel: false,
						success: function(res) {

						},
					});
					return;
				}
				item.renovation = true;
			},


			delPeoperBtn() {
				uni.showModal({
					title: '删除确认',
					content: '你是否移该装修人员信息！',
					cancelText: '否', // Set the text for the cancel button
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击了确认按钮');
							this.yichu();
						} else if (res.cancel) {
							console.log('用户点击了取消按钮');
						}
					}.bind(this) // Bind the Vue component's this context to the success callback
				});
			},

			yichu() {


				if (this.applyForm.worker_data.length != 1) {
					this.applyForm.worker_data.pop();
				}

			},



			//上传工人免冠照
			colseImg4(val, index) {
				val = null;
				if (!this.applyForm.worker_data.some(item => item.worker_image)) {
					this.imgFlag = true;
				}
				this.applyForm.worker_data[index].worker_image = null
				this.applyForm.worker_data[index].state1 = false
			},


			// 选择图片
			uoloadHouse4(index) {
				console.log(index)
				let _this = this;
				uni.showActionSheet({
					itemList: ['手机拍照', '本地图片上传'],
					success: function(res) {
						uni.showLoading({
							title: '上传中'
						});
						if (res.tapIndex == 0) {
							uni.chooseImage({
								count: 1,
								sizeType: ['original', 'compressed'],
								sourceType: ['camera'],
								success: function(res) {
									pathToBase64(res.tempFilePaths[0]).then(res => {
										_this.$request.api.image({
											imageBase64: res
										}).then(res => {
											_this.applyForm.worker_data[index]
												.worker_image = res.data.data;
											_this.applyForm.worker_data[index]
												.state1 = true
											_this.imgFlag = false;
											uni.hideLoading();

										})
									})
								}
							})
						} else {
							uni.chooseImage({
								count: 1,
								sizeType: ['original', 'compressed'],
								sourceType: ['album'],
								success: function(res) {
									pathToBase64(res.tempFilePaths[0]).then(res => {
										_this.$request.api.image({
											imageBase64: res
										}).then(res => {
											_this.applyForm.worker_data[index]
												.worker_image = res.data.data;
											_this.applyForm.worker_data[index]
												.state1 = true
											console.log(_this.applyForm
												.worker_data[index]
												.worker_image, "------------")
											_this.imgFlag = false;
											uni.hideLoading();
										})
									})
								}
							});
						}
					},
					fail: function(res) {}
				});
			},
			//跳转协议
			toMent() {
				plus.runtime.openURL('https://s.515f.com/#/pages/model/details?id=FB202302222579419')
			},
		}
	}